//---------------------------------------------------------------------------------
// Copyright (c) 2008 VoiceLynx Project
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
//     1. The origin of this software must not be misrepresented; you must not
//        claim that you wrote the original software. If you use this software
//        in a product, an acknowledgment in the product documentation would be
//        appreciated but is not required.
//
//     2. Altered source versions must be plainly marked as such, and must not be
//        misrepresented as being the original software.
//
//     3. This notice may not be removed or altered from any source
//        distribution.
//---------------------------------------------------------------------------------


#ifndef __VLUserSettings_h__
#define __VLUserSettings_h__

#define VL_CONFIG_KEY_SELECTED_SERVER     wxT("SelectedServer")
#define VL_CONFIG_KEY_SELECTED_PROFILE    wxT("SelectedProfile")

#define VL_CONFIG_EMPTY_STRING            wxT("")
#define VL_CONFIG_PATH_SEPERATOR          wxT("/")

#define VL_CONFIG_PATH_SERVERS            wxT("Servers")
#define VL_CONFIG_KEY_SERVER_NAME         wxT("Name")
#define VL_CONFIG_KEY_SERVER_HOST         wxT("Host")
#define VL_CONFIG_KEY_SERVER_PORT         wxT("Port")

#define VL_CONFIG_PATH_PROFILES           wxT("Profiles")
#define VL_CONFIG_KEY_PROFILE_NAME        wxT("Name")
#define VL_CONFIG_KEY_PROFILE_USERNAME    wxT("Username")
#define VL_CONFIG_KEY_PROFILE_PASSWORD    wxT("Password")

#include "VLPrerequisites.h"

#include "wx/config.h"

struct VLServerSettingsEntry
{
  VLServerSettingsEntry() : port(VL_DEFAULT_PORT) { }

  wxString name;
  wxString host;
  VLU16    port;
};

typedef std::map<wxString, VLServerSettingsEntry> VLServerSettingsEntryMap;

class VLServerSettings
{
public:
  void getServerNames(wxArrayString &names);
  bool getServer(const wxString &name, VLServerSettingsEntry &server);
  void setServer(const VLServerSettingsEntry &server);
  void deleteServer(const wxString &name);

  void write(wxConfigBase &config);
  void read(wxConfigBase &config);

private:
  VLServerSettingsEntryMap mServerMap;
};

struct VLProfileSettingsEntry
{
  wxString name;
  wxString username;
  wxString password;
};

typedef std::map<wxString, VLProfileSettingsEntry> VLProfileSettingsEntryMap;

class VLProfileSettings
{
public:
  void getProfileNames(wxArrayString &names);
  bool getProfile(const wxString &name, VLProfileSettingsEntry &profile);
  void setProfile(const VLProfileSettingsEntry &profile);
  void deleteProfile(const wxString &name);

  void write(wxConfigBase &config);
  void read(wxConfigBase &config);

private:
  VLProfileSettingsEntryMap mProfileMap;
};

#endif
